/**
 * Copyright &copy; 2012-2014 <a href="https://github.com/thinkgem/jeesite">JeeSite</a> All rights reserved.
 */
package com.thinkgem.jeesite.modules.employee.service;

import java.util.Date;
import java.util.Iterator;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.thinkgem.jeesite.common.persistence.Page;
import com.thinkgem.jeesite.common.service.CrudService;
import com.thinkgem.jeesite.modules.employee.entity.Employee;
import com.thinkgem.jeesite.modules.employee.dao.EmployeeDao;
import com.thinkgem.jeesite.modules.schedul.entity.SchedulingInformation;
import com.thinkgem.jeesite.modules.schedul.service.SchedulingInformationService;

/**
 * 人事信息管理Service
 *
 * @author hui.li
 * @version 2017-07-15
 */
@Service
@Transactional(readOnly = true)
public class EmployeeService extends CrudService<EmployeeDao, Employee> {

	@Autowired
	private EmployeeDao dao;

	@Autowired
	private SchedulingInformationService schedulingInformationService;

	public Employee get(String id) {
		return super.get(id);
	}

	public List<Employee> findList(Employee employee) {
		return super.findList(employee);
	}

	public Page<Employee> findPage(Page<Employee> page, Employee employee) {
		return super.findPage(page, employee);
	}

	/**
	 * 查询员工信息
	 *
	 * @param schclass
	 *            班次ID
	 * @param page
	 * @param employee
	 * @return
	 */
	public Page<Employee> findPageEmployee(String shiftId,
			Page<Employee> page, Employee employee) {
		// 查询所有员工
		if(null != shiftId && shiftId.length()>0)
		{
			employee.setShiftId(shiftId);
		}

		employee.setPage(page);
		page.setList(dao.findPageEmployee(employee));
		return page;
	}

	@Transactional(readOnly = false)
	public void save(Employee employee) {
		super.save(employee);
	}

	@Transactional(readOnly = false)
	public void delete(Employee employee) {
		super.delete(employee);
	}

	public Employee getcheckEmployeeNumber(String number) {
		return dao.getcheckEmployeeNumber(number);
	}

	public Page<Employee> queryExceptionEmployee(Page<Employee> page,
			Employee employee) {
		employee.setPage(page);
		page.setList(dao.queryExceptionEmployee(employee));
		return page;
	}

	/**
	 * 根据员工编号查询
	 *
	 * @param employeeNumer
	 * @return
	 */
	public Employee findOneByEmployeeNumer(String employeeNumer) {
		return dao.getcheckEmployeeNumber(employeeNumer);
	}

	/**
	 * 查询今日有排班的用户
	 * @param todayDate
	 * @return
	 */
	public List<Employee> findAllBySchedulingInformationAndDate(Date todayDate) {
		return dao.findAllBySchedulingInformationAndDate(todayDate);
	}
}